package com.xiaoyun;

import cn.hutool.core.io.file.FileReader;
import cn.hutool.core.io.file.FileWriter;
import cn.hutool.json.JSONUtil;

import java.io.File;
import java.util.Arrays;

public class ReplaceGog {

    public static void main(String[] args) {
        String property = System.getProperty("user.dir");
        String reFileName = "goggame-1423049311.info";
        File file = new File(property, reFileName);
        if (file.exists()) {
            FileReader reader = FileReader.create(file);
            String str = reader.readString();
            GogInfoEntity gogInfoEntity = JSONUtil.toBean(str, GogInfoEntity.class);
            gogInfoEntity.setLanguage("schinese");
            gogInfoEntity.setLanguages(Arrays.asList("zh-cn"));
            String strJson = JSONUtil.parseObj(gogInfoEntity, false, true).toStringPretty();
            System.out.println(strJson);
            FileWriter writer = new FileWriter(file);
            writer.write(strJson);
            System.out.println("替换成功");
        } else {
            System.out.println("当前路径为:" + property);
            System.out.println("当前路径不存在 goggame-1423049311.info");

        }

    }
}
